var Generator = require('yeoman-generator');

module.exports = class extends Generator {

    constructor(args, opts) {
        // Calling the super constructor is important so our generator is correctly set up
        super(args, opts);
    }

    async step1() {
        this.fs.copyTpl(
            this.templatePath('t.html'),
            this.destinationPath('public/index.html'),
            { title: 'Templating with Yeoman' }  // 传参到html中
        );
    }

    initPackage() {
        // Extend or create package.json file in destination path
        const pkgJson = {
            devDependencies: {
                eslint: '^3.15.0'
            },
            dependencies: {
                react: '^16.2.0'
            }
        };
        this.fs.extendJSON(this.destinationPath('package.json'), pkgJson);

        // https://stackoverflow.com/questions/68265615/yeoman-this-npminstall-is-not-a-function
        // this.npmInstall();
    }

    // async method1() {
    //     const answers = await this.prompt([
    //         {
    //             type: "input",
    //             name: "name",
    //             message: "Your project name",
    //             default: this.appname // Default to current folder name
    //         },
    //         {
    //             type: "confirm",
    //             name: "cool",
    //             message: "Would you like to enable the Cool feature?"
    //         }
    //     ]);

    //     this.log("app name", answers.name);
    //     this.log("cool feature", answers.cool);
    // }
};